package office.action.sale.form;

import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import office.bo.sale.impl.Customer;
import office.bo.sale.impl.CustomerInfo;
import platform.common.bo.IIdentifiableObj;
/**
 * 客户对应的Form
 * @author ZhangYQ
 *
 */
public class CustomerForm {
	private String id;
	private String companyName; //公司名称
	private String name;    //名称
	private int age;        //年龄
	private String sex;     //性别
	private String job;     //职务
	private String phone;   //手机
	private String telePhone;      //电话
	private String salesMan;      //业务员
	private String writeMan;      //登记人
	private Date  createDate;     //登记日期
	private Date  updateDate;     //修改日期
	private String salesManName; //业务员名称
	private Set<CustomerInfoForm> setInfo = new HashSet<CustomerInfoForm>();
	
	public IIdentifiableObj copyPropertiesToBO(IIdentifiableObj newObj) {
		Customer bo = (Customer)newObj;
		bo.setId(this.id);
		bo.setCompanyName(companyName);
		bo.setName(name);
		bo.setAge(age);
		bo.setSex(sex);
		bo.setJob(job);
		bo.setTelePhone(telePhone);
		bo.setPhone(phone);
		bo.setSalesMan(salesMan);
		bo.setWriteMan(writeMan);
		bo.setCreateDate(createDate);
		bo.setUpdateDate(updateDate);
		bo.setSalesManName(salesManName);
		return bo;
	}
	
	public void copyPropertiesFromBO(IIdentifiableObj baseBO) {
		Customer bo = (Customer)baseBO;
		this.id = bo.getId().toString();
		this.companyName = bo.getCompanyName();
		this.name = bo.getName();
		this.age = bo.getAge();
		this.sex = bo.getSex();
		this.job = bo.getJob();
		this.telePhone = bo.getTelePhone();
		this.phone = bo.getPhone();
		this.salesMan = bo.getSalesMan();
		this.writeMan = bo.getWriteMan();
		this.createDate = bo.getCreateDate();
		this.updateDate = bo.getUpdateDate();
		this.salesManName = bo.getSalesManName();
		for (Iterator<CustomerInfo> iterator = bo.getSetInfo().iterator(); iterator.hasNext();) {
			CustomerInfo customerInfo = (CustomerInfo) iterator.next();
			CustomerInfoForm customerInfoForm = new CustomerInfoForm();
			customerInfoForm.setId(customerInfo.getId().toString());
			customerInfoForm.setContent(customerInfo.getContent());
			customerInfoForm.setCustomerPropName(customerInfo.getCustomerProp().getName());
			customerInfoForm.setCustomerPropId(customerInfo.getCustomerProp().getId().toString());
			setInfo.add(customerInfoForm);
		}
	}
	
	public Set<CustomerInfoForm> getSetInfo() {
		return setInfo;
	}

	public void setSetInfo(Set<CustomerInfoForm> setInfo) {
		this.setInfo = setInfo;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getSalesMan() {
		return salesMan;
	}

	public void setSalesMan(String salesMan) {
		this.salesMan = salesMan;
	}

	public String getWriteMan() {
		return writeMan;
	}

	public void setWriteMan(String writeMan) {
		this.writeMan = writeMan;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getJob() {
		return job;
	}

	public void setJob(String job) {
		this.job = job;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getTelePhone() {
		return telePhone;
	}

	public void setTelePhone(String telePhone) {
		this.telePhone = telePhone;
	}

	public String getSalesManName() {
		return salesManName;
	}

	public void setSalesManName(String salesManName) {
		this.salesManName = salesManName;
	}
}
